home *** CD-ROM | disk | FTP | other *** search
- #ifndef __MOREFILESEXTRAS__
- #include <MoreFilesExtras.h>
- #endif
-
- #include "UtilsSys7.h"
- #include "FabLibResIDs.h"
- #include "Independents.h"
- #include "Internet.h"
-
- static ICError MyICLaunchURL(ICInstance inst, short STRid);
-
- #pragma segment Main
-
- void InternetLaunch(ICInstance inst, ICError *icErr, ModalFilterProcPtr filterProc, AEIdleProcPtr IdleFunct, short urlWanted)
- {
- Str31 errorStr;
- ICError locICErr;
-
- if (inst) {
- *icErr = MyICLaunchURL(inst, urlWanted);
- // UnloadSeg(MyICLaunchURL);
- }
- locICErr = *icErr;
- if (locICErr) {
- switch (locICErr) {
- case icPrefNotFoundErr:
- (void)StopAlert_AE(kALRT_ICMISSINGHELPER, filterProc, IdleFunct);
- break;
- default:
- NumToString(locICErr, errorStr);
- ParamText(errorStr, nil, nil, nil);
- (void)StopAlert_AE(kALRT_INTERNETCONFIG, filterProc, IdleFunct);
- }
- }
- }
-
-
- ICError SetCorrectFileType(const ICMapEntry *entry, const FSSpecPtr downloaded_file, ScriptCode theScript,
- Boolean needSetFileType)
- {
- FInfo info;
- Handle tempResource;
- OSErr err = noErr;
-
- if (needSetFileType) {
- err = FSpGetFInfoCompat(downloaded_file, &info);
- if (err == noErr) {
- info.fdType = entry->file_type;
- info.fdCreator = entry->file_creator;
- err = FSpSetFInfoCompat(downloaded_file, &info);
- if (err == noErr) {
- (void) BumpDate(downloaded_file->vRefNum, downloaded_file->parID, nil);
- if (FinderIsFront())
- PostEvent(osEvt, 0x01000003); // send a resume event
- }
- }
- }
- if (StrLength(entry->creator_app_name)) {
- tempResource = (Handle)NewString(entry->creator_app_name);
- if (tempResource)
- err = AddSTRHand2Doc(downloaded_file, entry->file_creator, entry->file_type, (StringHandle)tempResource, theScript);
- }
-
- return err;
- }
-
- #pragma segment Internet
-
- ICError MyICLaunchURL(ICInstance inst, short STRid)
- {
- StringHandle theString;
- long selStart, selEnd;
- const short nullstr = 0; // otherwise IC 1.1 will crash (doesn't like odd-aligned strings)
- ICError err;
-
- if (theString = GetString(STRid)) {
- selStart = 0L;
- selEnd = **theString;
- HLockHi((Handle) theString);
- err = ICLaunchURL(inst, (ConstStr255Param)&nullstr, (Ptr)*theString + 1, selEnd, &selStart, &selEnd);
- HUnlock((Handle) theString);
- // UnloadSeg(ICLaunchURL);
- }
- else
- err = ResError();
-
- return err;
- }
-
- ICError MyICLaunchURLText(ICInstance inst, Ptr s, UInt32 tLength)
- {
- //StringHandle theString;
- long selStart, selEnd;
- const short nullstr = 0; // otherwise IC 1.1 will crash (doesn't like odd-aligned strings)
- //ICError err;
-
- selStart = 0L;
- selEnd = tLength;
-
- return ICLaunchURL(inst, (ConstStr255Param)&nullstr, s, selEnd, &selStart, &selEnd);
- }
-
- ICError MyICCLaunchURLText(ICInstance inst, Ptr s, UInt32 tLength)
- {
- //StringHandle theString;
- long selStart, selEnd;
- const short nullstr = 0; // otherwise IC 1.1 will crash (doesn't like odd-aligned strings)
- //ICError err;
-
- selStart = 0L;
- selEnd = tLength;
-
- return ICCLaunchURL((internetConfigurationComponent)inst, (ConstStr255Param)&nullstr, s, selEnd, &selStart, &selEnd);
- }
-
- #pragma segment Init
-
- ICError MyICInit(ICInstance *inst, OSType creator)
- {
- ICError err;
-
- if (err = ICStart(inst, creator))
- *inst = nil;
- else
- err = ICFindConfigFile(*inst, 0, nil);
- //UnloadSeg(ICStart);
- return err;
- }
-
- ICError MyICInitNoSeg(ICInstance *inst, OSType creator)
- {
- ICError err;
-
- if (err = ICCStart((internetConfigurationComponent *)inst, creator))
- *inst = nil;
- else
- err = ICCFindConfigFile((internetConfigurationComponent)*inst, 0, nil);
- return err;
- }
-
-
- // check out the last #pragma segment !!!!!
-